package com.orientsec.autotest.project.system.autoRequesmappingDetail.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.orientsec.autotest.framework.aspectj.lang.annotation.Log;
import com.orientsec.autotest.framework.aspectj.lang.enums.BusinessType;
import com.orientsec.autotest.project.system.autoRequesmappingDetail.domain.AutoRequesmappingDetail;
import com.orientsec.autotest.project.system.autoRequesmappingDetail.service.IAutoRequesmappingDetailService;
import com.orientsec.autotest.framework.web.controller.BaseController;
import com.orientsec.autotest.framework.web.page.TableDataInfo;
import com.orientsec.autotest.framework.web.domain.AjaxResult;
import com.orientsec.autotest.common.utils.poi.ExcelUtil;

/**
 * 请求映射详情信息操作处理
 * 
 * @author autotest
 * @date 2020-01-14
 */
@Controller
@RequestMapping("/system/autoRequesmappingDetail")
public class AutoRequesmappingDetailController extends BaseController
{
    private String prefix = "system/autoRequesmappingDetail";
	
	@Autowired
	private IAutoRequesmappingDetailService autoRequesmappingDetailService;
	
	@RequiresPermissions("system:autoRequesmappingDetail:view")
	@GetMapping()
	public String autoRequesmappingDetail()
	{
	    return prefix + "/autoRequesmappingDetail";
	}
	
	/**
	 * 查询请求映射详情列表
	 */
	@RequiresPermissions("system:autoRequesmappingDetail:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(AutoRequesmappingDetail autoRequesmappingDetail)
	{
		startPage();
        List<AutoRequesmappingDetail> list = autoRequesmappingDetailService.selectAutoRequesmappingDetailList(autoRequesmappingDetail);
		return getDataTable(list);
	}


	/**
	 * 查询请求映射详情列表id
	 */
	@RequiresPermissions("system:autoRequesmappingDetail:list")
	@RequestMapping("/list/{id}")
	public String list(@PathVariable("id") Integer id,ModelMap mmap)
	{
		mmap.put("rmId",id);
		return prefix + "/autoRequesmappingDetail";
	}









	/**
	 * 导出请求映射详情列表
	 */
	@RequiresPermissions("system:autoRequesmappingDetail:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AutoRequesmappingDetail autoRequesmappingDetail)
    {
    	List<AutoRequesmappingDetail> list = autoRequesmappingDetailService.selectAutoRequesmappingDetailList(autoRequesmappingDetail);
        ExcelUtil<AutoRequesmappingDetail> util = new ExcelUtil<AutoRequesmappingDetail>(AutoRequesmappingDetail.class);
        return util.exportExcel(list, "autoRequesmappingDetail");
    }
	
	/**
	 * 新增请求映射详情
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存请求映射详情
	 */
	@RequiresPermissions("system:autoRequesmappingDetail:add")
	@Log(title = "请求映射详情", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(AutoRequesmappingDetail autoRequesmappingDetail)
	{		
		return toAjax(autoRequesmappingDetailService.insertAutoRequesmappingDetail(autoRequesmappingDetail));
	}

	/**
	 * 修改请求映射详情
	 */
	@GetMapping("/edit/{rmdId}")
	public String edit(@PathVariable("rmdId") Integer rmdId, ModelMap mmap)
	{
		AutoRequesmappingDetail autoRequesmappingDetail = autoRequesmappingDetailService.selectAutoRequesmappingDetailById(rmdId);
		mmap.put("autoRequesmappingDetail", autoRequesmappingDetail);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存请求映射详情
	 */
	@RequiresPermissions("system:autoRequesmappingDetail:edit")
	@Log(title = "请求映射详情", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(AutoRequesmappingDetail autoRequesmappingDetail)
	{		
		return toAjax(autoRequesmappingDetailService.updateAutoRequesmappingDetail(autoRequesmappingDetail));
	}
	
	/**
	 * 删除请求映射详情
	 */
	@RequiresPermissions("system:autoRequesmappingDetail:remove")
	@Log(title = "请求映射详情", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(autoRequesmappingDetailService.deleteAutoRequesmappingDetailByIds(ids));
	}
	
}
